<?php
/**
 * Crmlite_View_Helper_Fckeditor
 *
 * @final
 * @package Crmlite_App
 * @version $Id: Fckeditor.php 41 2007-09-03 02:06:05Z etng2004 $
 * @copyright 2006-2007 ETE.CN
 * @author Yi BO  <etng2004@gmail.com>
 * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
 */
class Crmlite_View_Helper_Fckeditor
{
	/**
     * view
     *
     * @var Zend_View_Interface
     * @access public
     */
	public $view;

	/**
     * setView
     *
     * @param Zend_View_Interface $view
     * @access public
     * @return Zend_View_Interface
     */
	public function setView(Zend_View_Interface $view)
	{
		$this->view = $view;
		return $this->view;
	}

	/**
	 * 生成编辑器代码
	 *
	 * @param string $name		字段名称
	 * @param string $value		字段内容
	 * @param string $toolbar	所用工具条类型，可选的有：Basic,Default,Custom
	 * @param int $height		输入框高度
	 * @param int $width		输入框宽度
	 * @param array $config		其他配置参数
	 * @return string 			编辑器代码
	 */
	public function fckeditor($name = null, $value = null, $toolbar = 'Basic', $height = null, $width = null, $config = null)
	{
		Zend_Loader::loadFile('fckeditor_php5.php', WWW_DIR . '/js/FCKeditor', $once = true);
		!empty($name) || $name = 'FCKeditor';
		$oFCKeditor = new FCKeditor($name) ;
		$oFCKeditor->BasePath  	= $this->view->wwwroot . '/js/FCKeditor/';
		$oFCKeditor->BasePath  	= $this->view->wwwroot . '/js/FCKeditor/';
		$oFCKeditor->ToolbarSet = $toolbar;
		$oFCKeditor->Height 	= $height != null ? $height : 200;
		if ($value 	!= null) $oFCKeditor->Value	= $value;
		if ($width 	!= null) $oFCKeditor->Width	= $width;
		$config['CustomConfigurationsPath'] = $this->view->wwwroot . '/js/FCKconfig.js';
		if ($config != null) $oFCKeditor->Config= $config;
		return $oFCKeditor->CreateHtml();
	}
}